import platform

# 根据平台设置Redis配置
if platform.system() == 'Windows':
    REDIS_HOST = 'localhost'
    REDIS_PORT = 6379
    # REDIS_PASSWORD = '123456'
    REDIS_DB_BROKER = 0
    REDIS_DB_BACKEND = 1
    
    # 构建Redis URL
    broker_url = f'redis://{REDIS_HOST}:{REDIS_PORT}/{REDIS_DB_BROKER}'
    result_backend = f'redis://{REDIS_HOST}:{REDIS_PORT}/{REDIS_DB_BACKEND}'
else:
    # 非Windows平台使用远程Redis
    broker_url = 'redis://:123456exhibition@redis:6379/1'
    result_backend = 'redis://:123456exhibition@redis:6379/2'

# 通用Celery配置
timezone = 'Asia/Shanghai'

# Windows特定配置
worker_pool_restarts = True
worker_max_tasks_per_child = 1
pool_options = {'processes': 1}
broker_connection_retry_on_startup = True

# 任务配置
task_serializer = 'json'
result_serializer = 'json'
accept_content = ['json']
task_track_started = True
task_time_limit = 3600
result_expires = 3600